package cn.z2huo.usercenter.authentication.app.interceptor;

import cn.z2huo.core.web.ResponseMessage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * <p>
 *
 * @author z2huo
 */
@RestControllerAdvice("cn.z2huo.usercenter.authentication.app.controller.login.test")
//@Order(2)
@Slf4j
public class WebExceptionHandler {

    @ExceptionHandler(Exception.class)
    public ResponseMessage handleException(Throwable e) {

        log.error(e.getMessage(), e);

        ResponseMessage responseMessage = new ResponseMessage();
        responseMessage.setSuccess(false)
                .setCode("9999")
                .setContent(e.getMessage());

        return responseMessage;

    }

}
